<template>
  <div class="net-rank-item">
    <div class="header">
      <div class="header-wrap">
        <div class="header-icon">
          <img :src="src" />
        </div>
        <div class="header-content">
          <div class="header-content-title">{{ text }}</div>
          <div class="header-content-icon">
            <div class="icon-play"></div>
            <div class="icon-add"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="main">
      <template v-for="(subitem, index) in rankList" :key="subitem">
        <net-rank-list :ranking="index + 1" :text="subitem.name" :index="index" />
      </template>
    </div>
    <div class="footer">
      <div class="footer-content">查看全部></div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'

import NetRankList from './rank-list.vue'

import { rankItemProps } from './props'

export default defineComponent({
  props: rankItemProps,
  components: {
    NetRankList
  },
  setup(props) {
    const src = computed(() => props.src)
    const text = computed(() => props.text)
    const rankList = computed(() => props.rankList?.slice(0, 10))

    return {
      src,
      text,
      rankList
    }
  }
})
</script>

<style scoped lang="less">
.net-rank-item {
  width: 33.3%;
  .header {
    width: 100%;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    .header-wrap {
      width: 80%;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      .header-icon {
        width: 70px;
        height: 70px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .header-content {
        height: 70px;
        width: 45px;
        margin-left: 10px;
        .header-content-title {
          font-weight: 600;
          font-size: 12px;
          color: #333;
        }
        .header-content-icon {
          margin-top: 5px;
          display: flex;
          justify-content: space-between;
          align-items: center;
          .icon-play {
            width: 18px;
            height: 18px;
            background: url('../../../assets/play_2.png');
            background-size: cover;
          }
          .icon-add {
            width: 18px;
            height: 18px;
            background: url('../../../assets/file_add.png');
            background-size: cover;
          }
        }
      }
    }
  }
  .main {
    width: 100%;
  }
  .footer {
    width: 100%;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #dbdbdb;
    .footer-content {
      width: 90%;
      text-align: right;
      font-size: 12px;
      color: #000;
      &:hover {
        cursor: pointer;
        text-decoration: underline;
      }
    }
  }
}
</style>
